var fs = require('fs');
var sql = fs.readFileSync("demo.sql").toString();
var sList = sql.replace(/--(.+?)\r\n/g, "").split(";"); //sql.replace(/--(.+?)\r\n/g, "") 删除注释
console.log('sList', sList);
sList.pop(); //删除最后的多余

var last = "";
for (let attr of sList) {
    let arr1 = attr.match(/INTO(.+?)\(/)[1];
    let arr2 = attr.match(/\((.+?)\)/g);
    last += `DELETE FROM ${arr1} WHERE ${arr2[0].split(",")[0].replace("(","")} = ${arr2[1].split(",")[0].replace("(","")} <br />`;
    // console.log('arr1:',arr1)
    // console.log('arr2:', arr2)
    // console.log('key1:', arr2[0].split(",")[0].replace("(", ""))
    // console.log('key2:', arr2[1].split(",")[0].replace("(", ""))
    // console.log(`DELETE FROM ${arr1} WHERE ${arr2[0].split(",")[0].replace("(","")} = ${arr2[1].split(",")[0].replace("(","")}`)
}
var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {
        'Content-type': 'text/html'
    });
    res.write(last);
    res.end("");
}).listen(3333);
console.log('打开浏览器： http://127.0.0.1:3333/');